//
//  NSObject+JXKJSON.m
//  jxk
//
//  Created by 徐汉卿 on 15/7/29.
//  Copyright (c) 2015年 jxk. All rights reserved.
//

#import "NSObject+JXKJSON.h"

@implementation NSObject (JXKJSON)
-(NSDictionary *)jsonToDic
{
    NSMutableString *str = [[NSMutableString alloc] initWithData:self encoding:NSUTF8StringEncoding];
                     NSLog(@"服务器返回的字典%@",str);
//    NSRange range = NSMakeRange(0, 12);
//    [str deleteCharactersInRange:range];
//    
//    [str deleteCharactersInRange:NSMakeRange(str.length -1, 1)];
//    //                 NSLog(@"%@",str);
//    
//    NSData *data2 = [str dataUsingEncoding:NSUTF8StringEncoding];

    
    NSDictionary *dic =  [NSJSONSerialization JSONObjectWithData:(NSData *)self options:NSJSONReadingMutableContainers error:nil];
    NSDictionary *dic2 = @{@"data":dic};
    return dic2;
}

/**
 *  直接转换
 *
 *  @return <#return value description#>
 */
-(NSDictionary *)jsonToDicdirect{
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:(NSData *)self options:NSJSONReadingMutableContainers error:nil];
     NSLog(@"服务器返回数据%@",dic);
    return dic;

}



-(NSDictionary *)JsonToDicNoLog{
//    NSMutableString *str = [[NSMutableString alloc] initWithData:self encoding:NSUTF8StringEncoding];
//
//    NSRange range = NSMakeRange(0, 12);
//    [str deleteCharactersInRange:range];
//    
//    [str deleteCharactersInRange:NSMakeRange(str.length -1, 1)];
//    //                 NSLog(@"%@",str);
//    
//    NSData *data2 = [str dataUsingEncoding:NSUTF8StringEncoding];
//    
    
    NSDictionary *dic =  [NSJSONSerialization JSONObjectWithData:(NSData *)self options:NSJSONReadingMutableContainers error:nil];
    NSDictionary *dic2 = @{@"data":dic};
    return dic2;


}

/**
 *  CJ的
 *
 *  @return <#return value description#>
 */
-(NSDictionary *)JsonToDic
{
    NSMutableString *str = [[NSMutableString alloc] initWithData:self encoding:NSUTF8StringEncoding];
    NSLog(@"服务器返回的字典%@",str);
    //    NSRange range = NSMakeRange(0, 12);
    //    [str deleteCharactersInRange:range];
    //
    //    [str deleteCharactersInRange:NSMakeRange(str.length -1, 1)];
    //    //                 NSLog(@"%@",str);
    //
    //    NSData *data2 = [str dataUsingEncoding:NSUTF8StringEncoding];
    
    
    NSDictionary *dic =  [NSJSONSerialization JSONObjectWithData:(NSData *)self options:NSJSONReadingMutableContainers error:nil];
    NSDictionary *dic2 = @{@"data":dic};
    return dic2;}




@end
